﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.views.components.sunface.states {
    import net.wooga.pets.views.components.sunface.*;
    import net.wooga.pets.utils.timeline.*;

    public class SunFaceDaytime extends SunFaceBaseState implements ISunFaceState {

        private static const DEFAULT_FRAME_LABEL:String = "happy";
        private static const IDLE_FRAME_LABEL_POOL:Array = ["cocktail", "bug", "headphones"];

        public function SunFaceDaytime(_arg1:SunFaceStateManager, _arg2:SequenceBasedStatesTimeline){
            super(_arg1, _arg2);
        }
        override public function initiate():void{
            timeline.gotoAndStop(DEFAULT_FRAME_LABEL);
        }
        override public function talk():void{
            this.stop();
            this.context.currentState = this.context.getStateByLookupKey(SunFaceStateManager.DAYTIME_TALKING);
            this.context.talk();
        }
        override public function idle():void{
            if (!isPlaying){
                this.playFromLabel(this.pickRandomIdleFrameLabel());
            };
        }
        override public function click():void{
            this.stop();
            this.context.currentState = this.context.getStateByLookupKey(SunFaceStateManager.DAYTIME_CLICK);
            this.context.click();
        }
        override public function stop():void{
            this.interrupt();
        }
        override protected function onTimelineAnimationFinished(_arg1:String):void{
            if (_arg1 == DEFAULT_FRAME_LABEL){
                this.context.currentState = this.context.defaultState;
                this.context.initiate();
            };
        }
        private function pickRandomIdleFrameLabel():String{
            return (IDLE_FRAME_LABEL_POOL[int((Math.random() * IDLE_FRAME_LABEL_POOL.length))]);
        }

    }
}//package net.wooga.pets.views.components.sunface.states 
